package com.ruoyi.system.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WmsInventoryHistory;
import com.ruoyi.system.service.IWmsInventoryHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存记录Controller
 *
 * @author ruoyi
 * @date 2025-06-21
 */
@RestController
@RequestMapping("/system/wmsInventoryHistory")
public class WmsInventoryHistoryController extends BaseController
{
    @Autowired
    private IWmsInventoryHistoryService wmsInventoryHistoryService;

    /**
     * 查询库存记录列表
     */
    @SaCheckPermission("system:wmsInventoryHistory:list")
    @GetMapping("/list")
    public TableDataInfo<WmsInventoryHistory> list(WmsInventoryHistory wmsInventoryHistory, PageQuery pageQuery)
    {
        return wmsInventoryHistoryService.selectWmsInventoryHistoryList(wmsInventoryHistory,pageQuery);
    }

    /**
     * 导出库存记录列表
     */
    /*@SaCheckPermission("system:wmsInventoryHistory:export")
    @Log(title = "库存记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsInventoryHistory wmsInventoryHistory)
    {
        List<WmsInventoryHistory> list = wmsInventoryHistoryService.selectWmsInventoryHistoryList(wmsInventoryHistory);
        ExcelUtil<WmsInventoryHistory> util = new ExcelUtil<WmsInventoryHistory>(WmsInventoryHistory.class);
        util.exportExcel(response, list, "库存记录数据");
    }*/

    /**
     * 获取库存记录详细信息
     */
    @SaCheckPermission("system:wmsInventoryHistory:query")
    @GetMapping(value = "/{id}")
    public R<WmsInventoryHistory> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(wmsInventoryHistoryService.selectWmsInventoryHistoryById(id));
    }

    /**
     * 新增库存记录
     */
    @SaCheckPermission("system:wmsInventoryHistory:add")
    @Log(title = "库存记录", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Void> add(@RequestBody WmsInventoryHistory wmsInventoryHistory)
    {
        return toAjax(wmsInventoryHistoryService.insertWmsInventoryHistory(wmsInventoryHistory));
    }

    /**
     * 修改库存记录
     */
    @SaCheckPermission("system:wmsInventoryHistory:edit")
    @Log(title = "库存记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Void> edit(@RequestBody WmsInventoryHistory wmsInventoryHistory)
    {
        return toAjax(wmsInventoryHistoryService.updateWmsInventoryHistory(wmsInventoryHistory));
    }

    /**
     * 删除库存记录
     */
    @SaCheckPermission("system:wmsInventoryHistory:remove")
    @Log(title = "库存记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R<Void> remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsInventoryHistoryService.deleteWmsInventoryHistoryByIds(ids));
    }
}
